package com.zl.learning.thread.thread_daemon;

public class JoinThread extends Thread {
    public JoinThread(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i=0;i<100;i++){
            System.out.println(getName()+" "+i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 100; i++) {
            if(i==20){
                JoinThread jt = new JoinThread("join Thread");
                JoinThread jt2 = new JoinThread("join Thread2");
                jt.start();
                jt2.start();
                jt.join();
                jt2.join();
            }
            System.out.println(Thread.currentThread().getName()+" " +i);
        }
    }
}
